package com.aier.service.rights.impl;

import com.aier.bean.rights.MenuNode;
import com.aier.mapper.rights.MenuNodeMapper;
import com.aier.service.rights.MenuNodeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 菜单-路由节点实现类
 * **/
@Service
public class MenuNodeServiceImpl implements MenuNodeService {

    @Autowired
    private MenuNodeMapper menuNodeMapper;

    @Override
    public List<MenuNode> getAllMenuNode() {
        return menuNodeMapper.selectList(null);
    }

    @Override
    public MenuNode getMenuNodeByNodeId(String nodeId) {
        QueryWrapper<MenuNode> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(MenuNode::getNodeId,nodeId);
        return menuNodeMapper.selectOne(queryWrapper);
    }

    @Override
    public boolean isExistMenuNode(MenuNode menuNode, List<MenuNode> menuNodeList) {
        return menuNodeList.stream().anyMatch(menu -> menu.getNodeId().equals(menuNode.getNodeId()));
    }
}
